'''
Created on Nov 21, 2009

@author: mkiyer

Initialization code for the ucsc package
'''
import veggie.app
import veggie.db.refdb as refdb
import os
import subprocess

# setup software root path to point to chipseq applications
sw_root = os.path.join(veggie.app.sw_root, 'ucsc')

def wigToBigWig(wigglefile, bigwigfile, genome="hg18"):
    executable = os.path.join(sw_root, 'bin', 'wigToBigWig')
    chrom_sizes = refdb.get_chrom_sizes(genome)
    return subprocess.call([executable, wigglefile, chrom_sizes, bigwigfile])

def bedToBigBed(bedfile, bigbedfile, genome="hg18"):
    executable = os.path.join(sw_root, 'bin', 'bedToBigBed')
    chrom_sizes = refdb.get_chrom_sizes(genome)
    return subprocess.call([executable, bedfile, chrom_sizes, bigbedfile])

def bedClip(inbedfile, outbedfile, genome="hg18"):
    executable = os.path.join(sw_root, 'bin', 'bedClip')
    chrom_sizes = refdb.get_chrom_sizes(genome)
    subprocess.call([executable, inbedfile, chrom_sizes, outbedfile])